home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 Super Collection / Windows 95 Super Collection.iso / win95 / programm / vbxstd20 / cstr30.h_ / CSTR30.H
Encoding:
C/C++ Source or Header  |  1995-07-04  |  32.6 KB  |  726 lines

  1. // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2. //
  3. //        CSTR30.H
  4. //        String Studio 3.0 
  5. //        20.june.1995
  6. //        «HEXANET, COPYRIGHT HEXANET 1993-1995, ALL RIGHTS RESERVED
  7. //        You can distribute this file as long as you distribute
  8. //        the full CSTR package ( not the CSTR30A.CPP nor CSTR30B.CPP files! )
  9. // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  10. // 
  11. //        To compile: use the String Studio STDAFX.H template and copy the necessary
  12. //        #include to the STDAFX.H file of your current project. Then link with 
  13. //        CSTR30W.LIB (for Win16) or CSTR30NT.LIB for Win95/NT. You must not use _DEBUG with
  14. //        these evaluation LIB files. See CSTR.HLP for details.
  15. // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  16. //        If you are a registered user, you will define _REGISTERED in your STDAFX.H precompiled header before 
  17. //        you compile this file and the String Studio *.CPP files to avoid the nag screens.
  18. // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  19.  
  20. #ifndef __cplusplus
  21. #error require C++ compilation (use a .cpp suffix)
  22. #endif
  23.  
  24. #ifndef _CSTR
  25.     #define _CSTR
  26. #endif
  27. #ifndef _CSTR30
  28.     #define _CSTR30
  29. #endif
  30. #ifndef _CMEM
  31.     #define _CMEM
  32. #endif
  33. #ifndef _CMEM30
  34.     #define _CMEM30
  35. #endif
  36.  
  37. // -----------------------------------------------------------------------
  38. //    You can build different String Studio versions
  39. //    With or without the following components
  40. //    (to remove some parts, put // before #define):
  41. #define _CSTR30_HASMOREBASIC
  42. #define _CSTR30_HASFILE
  43. #define _CSTR30_HASINI
  44. #define _CSTR30_HASWINCTL
  45. #define _CSTR30_HASNUM
  46. #define _CSTR30_HASCTIM
  47. #define _CSTR30_HASCFFIND
  48. #define _CSTR30_HASUNC
  49. #define _CSTR30_HASCTL3D     
  50. #define _CSTR30_HASFINDWORD
  51. #define _CSTR30_HASCHAR
  52.  
  53. #ifdef _CSTR30_HASWINCTL
  54.     #ifndef _WINDOWS
  55.         #undef _CSTR30_HASWINCTL
  56.     #endif
  57. #endif              
  58.  
  59. #ifdef _CSTR30_HASNUM
  60.     #ifndef _CSTR30_HASCHAR
  61.         #define _CSTR30_HASCHAR
  62.     #endif
  63. #endif
  64.  
  65. #ifdef _WIN32
  66.     #ifdef _CSTR30_HASFILE
  67.         #ifndef _CSTR30_HASCFFIND
  68.             #define _CSTR30_HASCFFIND
  69.         #endif
  70.     #endif
  71. #endif
  72.  
  73. #ifdef _CSTR30_HASCFFIND
  74.     #ifndef _CSTR30_HASCTIM
  75.         #define _CSTR30_HASCTIM
  76.     #endif 
  77.     #ifndef _CSTR30_HASFILE
  78.         #define _CSTR30_HASFILE
  79.     #endif
  80. #endif
  81.  
  82. //    Tell us which components we are using...
  83. #ifndef _ALREADY_DISPLAYED
  84. #ifdef _CSTR30_HASMOREBASIC
  85.     #pragma message("String Studio 3.0: adding MOREBASIC functions group.")
  86. #endif
  87. #ifdef _CSTR30_HASFILE
  88.     #pragma message("String Studio 3.0: adding FILE functions group.")
  89. #endif
  90. #ifdef _CSTR30_HASINI
  91.     #pragma message("String Studio 3.0: adding INI functions group.")
  92. #endif
  93. #ifdef _CSTR30_HASWINCTL
  94.     #pragma message("String Studio 3.0: adding WINCTL functions group.")
  95. #endif
  96. #ifdef _CSTR30_HASNUM
  97.     #pragma message("String Studio 3.0: adding NUM functions group.")
  98. #endif
  99. #ifdef _CSTR30_HASCTIM
  100.     #pragma message("String Studio 3.0: adding CTIM functions group.")
  101. #endif
  102. #ifdef _CSTR30_HASCFFIND
  103.     #pragma message("String Studio 3.0: adding CFFIND functions group.")
  104. #endif
  105. #ifdef _CSTR30_HASUNC
  106.     #pragma message("String Studio 3.0: adding UNC functions group.")
  107. #endif
  108. #ifdef _CSTR30_HASCTL3D     
  109.     #pragma message("String Studio 3.0: adding CTL3D functions group.")
  110. #endif
  111. #ifdef _CSTR30_HASFINDWORD
  112.     #pragma message("String Studio 3.0: adding FINDWORD functions group.")
  113. #endif
  114. #ifdef _CSTR30_HASCHAR
  115.     #pragma message("String Studio 3.0: adding CHAR functions group.")
  116. #endif
  117. #endif    //    _ALREADY_DISPLAYED
  118.  
  119. #ifndef LPTSTR
  120.     #define LPTSTR LPSTR
  121. #endif
  122. #ifndef LPCTSTR
  123.     #define LPTCSTR LPCSTR
  124. #endif
  125.  
  126. // -----------------------------------------------------------------------
  127. //    Old MFCs will use CStr::Format
  128. #if _MFC_VER < 0x0252
  129.     #ifndef _ALREADY_DISPLAYED
  130.         #pragma message("You are using an old MFC verion...")
  131.     #endif
  132.     #define _OLD_MFC
  133. #endif
  134.  
  135. #ifdef _DOS
  136.     #define _REGISTERED            // No nag screen with DOS...               
  137.     #define TA_LEFT            0x0000
  138.     #define TA_RIGHT       0x0002
  139.     #define TA_CENTER     0x0006
  140.     #ifndef _ALREADY_DISPLAYED
  141.         #pragma error( "Sorry: DOS no more supported!")
  142.     #endif
  143. #else
  144.     #ifndef _ALREADY_DISPLAYED
  145.     #ifdef _WIN32
  146.         #ifdef _REGISTERED
  147.             #pragma message("String Studio 3.0 (REGISTERED): Using the Win32 version...")
  148.         #else
  149.             #pragma message("String Studio 3.0 (UNREGISTERED): Using the Win32 version...")
  150.         #endif                   
  151.     #else
  152.         #ifdef _REGISTERED
  153.             #pragma message("String Studio 3.0 (REGISTERED): Using the Win16 version...")
  154.         #else
  155.             #pragma message("String Studio 3.0 (UNREGISTERED): Using the Win16 version...")
  156.         #endif                   
  157.     #endif
  158.     #endif    //    _ALREADY_DISPLAYED
  159. #endif
  160.  
  161.             #ifndef _WIN32        // ---> Win32 file attributes (we use them instead of the DOS 16 attrib)
  162.                 #define FILE_ATTRIBUTE_READONLY         0x00000001  
  163.                 #define FILE_ATTRIBUTE_HIDDEN           0x00000002  
  164.                 #define FILE_ATTRIBUTE_SYSTEM           0x00000004  
  165.                 #define FILE_ATTRIBUTE_DIRECTORY        0x00000010  
  166.                 #define FILE_ATTRIBUTE_ARCHIVE          0x00000020  
  167.                 #define FILE_ATTRIBUTE_NORMAL           0x00000080  
  168.             #endif
  169.             
  170.     class CStr;
  171.  
  172. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  173. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  174. //    AFX global functions
  175. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  176. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  177.  
  178.     //    ----------------------------------------------------------------------
  179.     //    infos
  180.     //    ----------------------------------------------------------------------
  181.     #ifdef _WINDOWS    
  182.         #define FREERES_GLOBAL                    0              // System
  183.         #define FREERES_USER                       1
  184.         #define FREERES_GDI                          2
  185.         #define FREERES_MEM                        3
  186.         #define FREERES_DISK                       4               // in Kb.
  187.     #ifdef _CSTR30_HASMOREBASIC
  188.         extern UINT AfxGetFreeResRate( int iResCode );
  189.         extern unsigned long AfxGetFreeResValue( int iResCode );
  190.     #endif    //    _CSTR30_HASMOREBASIC
  191.         extern BOOL AfxHasWin4Look();    //    3.0
  192.     #ifdef _CSTR30_HASINI
  193.         extern int AfxGetPrecision();
  194.         extern CStr AfxGetDecimalPoint();
  195.         extern CStr AfxGetThousandsSeparator();
  196.         extern CString AfxGetShortDateFormat();
  197.         extern CString AfxGetLongDateFormat();
  198.     #endif     //    _CSTR30_HASINI
  199.     
  200.     //    ----------------------------------------------------------------------
  201.     //    windows specific
  202.     //    ----------------------------------------------------------------------
  203.     extern void AfxSleep(int iSecs, BOOL bBackGnd = TRUE );    // 3.0
  204.     extern void AfxGiveTheHand( HWND hDialog = NULL );        // 3.0
  205.     #ifdef _CSTR30_HASCTL3D
  206.         // Ctl3D ( release 2.0 only ) wrappers for the TRUE MFC applications
  207.         #define        AFXCTL3D_OK                                0          // Ok to use CTL3D
  208.         #define        AFXCTL3D_NOTFOUND                1            // The user doesn' t own the DLL (CTL3DV2.DLL or CTL3D32.DLL)
  209.         #define        AFXCTL3D_BADDLL                     2           // Error
  210.         #define     AFXCTL3D_ERROR                       3            // Error
  211.         #ifndef CTL3D_ALL
  212.             #define CTL3D_ALL                0xffff
  213.         #endif
  214.         extern "C" int AfxCtl3dLoad(  );    // 3.0
  215.         extern "C" BOOL AfxCtl3dUnload(  );
  216.         extern "C" BOOL AfxCtl3dNewColors(  );
  217.         extern "C" BOOL AfxCtl3dSubclassCtl( HWND hItem );    // 3.0
  218.     #endif    //    _CSTR30_HASCTL3D
  219.     #ifdef _CSTR30_HASINI
  220.         extern BOOL AfxWriteWindowPos( HWND hWnd , BOOL bUseParent = FALSE, LPCTSTR szWindowName = "Main", LPCTSTR szIni = NULL );
  221.         extern RECT  AfxGetWindowPos( HWND hWnd = NULL, LPCTSTR szWindowName = "Main", LPCTSTR szIni = NULL, BOOL bMove = TRUE, BOOL bSize = FALSE);                
  222.     #endif    //    _CSTR30_HASINI
  223.     extern BOOL AfxCenterWindow( CWnd* pWnd, BOOL bAbsolute = TRUE );
  224.     #ifdef _CSTR30_HASWINCTL
  225.         // Maybe the following functions will simplify your MFC dialogs programming...
  226.         extern BOOL AfxEnableDlgItem( CWnd* pWnd, UINT id = 1, BOOL bEnabled = TRUE );
  227.         extern BOOL AfxEnableOK( CWnd* pWnd, BOOL bEnabled = TRUE);
  228.         extern BOOL AfxEnableCANCEL( CWnd* pWnd, BOOL bEnabled = TRUE);
  229.         extern void AfxSetFocus( CWnd* pWnd, UINT id = 1 );
  230.         extern void AfxSetDefButton( CWnd* pWnd, UINT id = 1);
  231.         extern void AfxActivateEdit( CWnd* pWnd, UINT id );
  232.     #endif    //    _CSTR30_HASWINCTL
  233.     
  234.     //    ----------------------------------------------------------------------
  235.     //    files
  236.     //    ----------------------------------------------------------------------
  237.     #ifdef _CSTR30_HASCTIM
  238.         extern BOOL AfxSetFileTime( LPCTSTR szSrcFile, LPCTSTR szDestFile );        // 3.0
  239.         extern BOOL AfxTouchFile( LPCTSTR szFile );    //    3.0
  240.         extern BOOL AfxSetFileAttributes( LPCTSTR szSrcFile, LPCTSTR szDestFile );        // 3.0
  241.     #endif    //    _CSTR30_HASCTIM
  242. #endif // windows
  243.  
  244.     //    ----------------------------------------------------------------------
  245.     //    misc
  246.     //    ----------------------------------------------------------------------
  247.     #define AfxRoundToInt(x) floor((x)+0.5)
  248.     #ifdef _CSTR30_HASNUM
  249.         extern double AfxRound( double x, int precision = 2);
  250.     #endif    //    _CSTR30_HASNUM
  251.     #ifdef _CSTR30_HASFINDWORD
  252.     extern BOOL AfxFindWordInFile( LPCTSTR szFile, LPCTSTR szWord, unsigned long iFromLine = 0L, int iFromCursor = 0, 
  253.                                       unsigned long* rLineValue = NULL, int* rCursorValue =NULL, BOOL bExact = TRUE, BOOL bMatchCase = FALSE );
  254.     #endif    //    _CSTR30_HASWFINDWORD
  255.     extern BOOL AfxCheckFileName( CString& sValue, BOOL bNoWildCards = TRUE);            
  256.     extern BOOL AfxIsDateValid( int iYear, int iMonth, int iDay );
  257.  
  258.  
  259.  
  260. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  261. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  262. //    class CMem    [3.0]
  263. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  264. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  265.  
  266.         #ifdef _WINDOWS
  267.           class CMem        //    3.0
  268.               {
  269.                public:
  270.                   CMem ();
  271.                   CMem (DWORD dwSize, UINT uFlags = GHND);
  272.                   ~CMem ();
  273.                   void __far * Alloc (DWORD dwSize, UINT uFlags = GHND);
  274.                   void __far * ReAlloc (DWORD dwSize, UINT uFlags = GHND);
  275.                   void Free ();
  276.                   HGLOBAL GetHandle () {return (m_hGlb); };
  277.                   DWORD GetSize () {return (m_dwSize); };
  278.                   void __far * GetPtr() {return ((void __far *) ((char __far *)m_pvMem)); };
  279.                   BOOL IsValid() { return ( (m_hGlb != NULL) && ( m_dwSize >= m_dwRequest )); };
  280.             
  281.                protected:
  282.                   HGLOBAL m_hGlb;
  283.                   void __far * m_pvMem;
  284.                   DWORD m_dwSize, m_dwRequest;
  285.               };
  286.         #endif    //    _WINDOWS
  287.  
  288.     
  289. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  290. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  291. //    class CStr
  292. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  293. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  294.     typedef signed long SLong;
  295.     #define COPYTO_SUCCESS            0
  296.     #define COPYTO_NOTFOUND          1
  297.     #define COPYTO_BADSRCFNAME     2
  298.     #define COPYTO_BADDESTFNAME     3
  299.     #define COPYTO_NOMEM             4
  300.     #define COPYTO_CANTCREATEDEST             5
  301.     #define COPYTO_READERROR     6
  302.     #define COPYTO_WRITEERROR    7
  303.     #define COPYTO_DISKFULL            8
  304.     #define COPYTO_CANTDELETEDEST    9
  305.     #define COPYTO_NOATTRIB            10    // more a warning than an error code
  306.     #define COPYTO_NODATE             11    // more a warning than an error code
  307.     #define COPYTO_CANTDELETESRC    12    // more a warning than an error code
  308.                 
  309.             class CStr : public CString
  310.                 { 
  311.                 public:
  312.                 // ----------------------------------------------------------
  313.                 //    Constructors
  314.                 // ----------------------------------------------------------
  315.                 #ifdef _REGISTERED
  316.                     CStr( void ):  CString( ) {};                                                        
  317.                     CStr( const CString& stringSrc): CString( stringSrc ) {};
  318.                     CStr( char ch, int nRepeat = 1): CString(ch, nRepeat ) {};
  319.                     CStr( const char* psz): CString( psz ) {};
  320.                     CStr( const char* pch, int nLength): CString( pch, nLength ) {};
  321.                     #ifdef _WINDOWS                                            
  322.                         CStr( UINT iStringID, HINSTANCE hInstance = NULL ): CString() 
  323.                             { 
  324.                             if ( hInstance == NULL ) this->LoadString ( (UINT)iStringID);
  325.                                 else
  326.                                 {
  327.                                 ::LoadString( hInstance, (UINT)iStringID, this->GetBuffer(256), 256 );
  328.                                 this->ReleaseBuffer();
  329.                                 } 
  330.                             }; 
  331.                     #endif                                    
  332.                 #else
  333.                     CStr( void ); 
  334.                     CStr( const CString& stringSrc); 
  335.                     CStr( char ch, int nRepeat = 1);
  336.                     CStr( const char* psz); 
  337.                     CStr( const char* pch, int nLength); 
  338.                     #ifdef _WINDOWS                                            
  339.                         CStr( UINT iStringID, HINSTANCE hInstance = NULL );
  340.                     #endif
  341.                 #endif
  342.                 // ----------------------------------------------------------
  343.                 //    Basics
  344.                 // ----------------------------------------------------------
  345.                 CString Trim( void );    //    3.0: Now deletes CR and LF codes
  346.                 CString TrimBegin( void );
  347.                 CString TrimEnd( void );
  348.                 unsigned int Count( LPCTSTR szSubString ) const;
  349.                 unsigned int Count( char szSubString ) const;
  350.                 #ifdef _CSTR30_HASMOREBASIC
  351.                     CStr Align( int aMode, int iSize );
  352.                 #endif
  353.                 CStr ExtractToEnd( int iFrom, char szSeparator );
  354.                 CStr ExtractToEnd( int iFrom, LPCTSTR szSeparator = ";" );
  355.                 CStr ExtractToBegin( int iFrom, char szSeparator );
  356.                 CStr ExtractToBegin( int iFrom, LPCTSTR szSeparator = ";" );
  357.                 CStr Delete( unsigned PFirst = 0, unsigned Plength = 0 );
  358.                   CStr Replace( LPCTSTR szOld, LPCTSTR szNew = "" );
  359.                   CStr Replace( char szOld, char szNew  );
  360.                   CStr Insert( LPCTSTR szSub, int Pos  = 0 );
  361.                 CStr Insert( char szSub, int Pos  = 0 );
  362.                 CStr Extract( int Pos = 1, LPCTSTR szDelimit = "\t" ); 
  363.                 CStr Extract( int Pos, char szDelimit );
  364.                 char& operator() (int Index );    // new 2.0: Replace the [] operator
  365.                 virtual LPTSTR CStr::GetBuffer( int size = 0);
  366.                 #ifdef _CSTR30_HASMOREBASIC
  367.                     CStr FirstUpper( void );
  368.                       CStr Blank( void );
  369.                       CStr Replicate( char cMotif = ' ', int iLen = 1 );
  370.                   #endif    //    _CSTR30_HASMOREBASIC
  371.                   CStr AddLF( void );                   
  372.                   CStr CheckSize( int iLength = 255, BOOL bAddPoints = TRUE ); 
  373.                   CStr CheckDirSize( int iLength = 60, BOOL bShift = TRUE );
  374.             
  375.                 // ----------------------------------------------------------
  376.                 //    Basics - Windows specific
  377.                 // ----------------------------------------------------------
  378.             #ifdef _WINDOWS 
  379.                 CStr FromRes( UINT iStringID, HINSTANCE hInstance = NULL, LPCTSTR szItem1 = NULL, LPCTSTR szItem2 = NULL,  LPCTSTR szItem3 = NULL, LPCTSTR szItem4 = NULL, 
  380.                                         LPCTSTR szItem5 = NULL, LPCTSTR szItem6 = NULL, LPCTSTR szItem7 = NULL, LPCTSTR szItem8 = NULL, LPCTSTR szItem9 = NULL );
  381.                 #ifdef _CSTR30_HASMOREBASIC
  382.                     #ifndef _WIN32
  383.                         int GetTextWidth( HDC hDC, int iTabCount = 0, int far* pTabList = NULL ) const;    
  384.                         int GetTextHeight( HDC hDC , int iTabCount = 0, int far* pTabList = NULL ) const;
  385.                     #endif    //    !_WIN32
  386.                     int GetTextWidth( CDC* pDC , int iTabCount = 0, int far* pTabList = NULL ) const;
  387.                     int GetTextWidth( CWnd* pWnd , int iTabCount = 0, int far* pTabList = NULL ) const;
  388.                     int GetTextHeight( CDC* pDC , int iTabCount = 0, int far* pTabList = NULL ) const;
  389.                     int GetTextHeight( CWnd* pWnd , int iTabCount = 0, int far* pTabList = NULL ) const;
  390.                 #endif    //    _CSTR30_HASMOREBASIC
  391.                 CStr GetWindowTitle( CWnd* pWnd, BOOL bIncDocName = FALSE );        
  392.                 CStr GetWindowTitle( HWND hWnd, BOOL bIncDocName = FALSE );        
  393.                 #ifdef _CSTR30_HASMOREBASIC
  394.                     CSize TabbedTextOut( CDC* pDC, int X, int Y, int iTabCount = 0, int far* TabList = NULL ) const; 
  395.                     CSize TabbedTextOut( CWnd* pWnd, int X, int Y, int iTabCount = 0, int far* TabList = NULL ) const; 
  396.                     int GetClassName( CWnd* pWnd );                                
  397.                     int GetClassName( HWND hWnd );                                
  398.                 #endif
  399.                 CStr GetWinfileAssociation( LPCTSTR szExtension );    
  400.                 int MB( CWnd* pWnd = NULL, LPCTSTR szTitle = NULL, UINT mbType = MB_OK | MB_ICONINFORMATION ) const;
  401.                 #ifdef _CSTR30_HASWINCTL
  402.                     int GetDlgItemText( CWnd* pWnd, UINT iControl );
  403.                     void ToCtl( CWnd* pWnd, int iCtl, BOOL bAltMode = FALSE ) const;
  404.                     CStr FromCtl( CWnd* pWnd, int iCtl );       
  405.                 #endif    //    _CSTR30_HASWINCTL
  406.                 CStr sprintf( LPCTSTR szFormat, ... );    // 3.0
  407.             #endif    // _WINDOWS
  408.                 
  409.                 // ----------------------------------------------------------
  410.                 //    Nums
  411.                 // ----------------------------------------------------------
  412.             #ifdef _CSTR30_HASNUM
  413.                 CString From( long data, int base = 10, LPCTSTR szSeparator = ",");
  414.                 CString From( unsigned long data, int base = 10, LPCTSTR szSeparator = ",");
  415.                 CString From( int data, int base = 10, LPCTSTR szSeparator = ",");
  416.                 CString From( unsigned int data, int base = 10, LPCTSTR szSeparator = ",");    // 2.0
  417.                 CString From( double data, int precision = 2, LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." );
  418.                 CStr NumFormat( double dValue, LPCTSTR szFormat = "###,###,###,###.00;-###,###,###,###.00; ", LPCTSTR szDecimalPoint = ".", LPCTSTR szThousandSeparator ="," );
  419.                 CStr NumUnformat( LPCTSTR szDecimalPoint = "." );
  420.                 signed int ToInt( LPCTSTR szSeparator = ",") const;
  421.                 UINT ToUINT( LPCTSTR szSeparator = ",") const;
  422.                 signed long ToLong( LPCTSTR szSeparator = ",") const;
  423.                 unsigned long ToULong( LPCTSTR szSeparator = ",") const;
  424.                 float ToFloat( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const;
  425.                 double ToDouble( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const;
  426.                 CStr Round( LPCTSTR szDecimalPoint = ".");
  427.                 BOOL IsDigit( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const;
  428.                   BOOL IsInRange( double dMini = 0, double dMaxi  = 100 ) const;
  429.             #endif    // _CSTR30_HASNUM
  430.             
  431.                 // ----------------------------------------------------------
  432.                 //    Files
  433.                 // ----------------------------------------------------------
  434.             #ifdef _CSTR30_HASFILE
  435.                 BOOL IsFileName( BOOL bAllowWildCards = FALSE ) const;
  436.                 BOOL IsPathName(  ) const;
  437.                 BOOL IsFullFileName( BOOL bNoWildCards = TRUE ) const;
  438.                 CStr     GetPathValue( );
  439.                 CStr     GetFileNameValue( );
  440.                 CStr     CheckFullFileName( BOOL bNoWildCards = TRUE, BOOL bAddSlash  =FALSE);
  441.                 CStr     CheckFileExtension( LPCTSTR szExtension, BOOL bForceExtension = FALSE);
  442.                 BOOL  ChDir( BOOL bIncludesFName = FALSE, BOOL bCreateDir = FALSE) const;
  443.                 BOOL  MkDir( BOOL bIncFile = FALSE) const;
  444.                 BOOL RemoveDir( BOOL bIncFile = FALSE, BOOL bDeleteRO = TRUE ) const;            // 3.0
  445.                 BOOL DoesFileExist( ) const;
  446.                 BOOL DoesDirExist( BOOL bIncFile = FALSE) const;
  447.                 
  448.                 DWORD GetFileAttributes( ) const;  // 3.0
  449.                 BOOL IsRDOnly( ) { return (BOOL)( CStr::GetFileAttributes() & FILE_ATTRIBUTE_READONLY ); }; // 3.0
  450.                 BOOL SetFileAttributes( DWORD dwNewAttrib ) const;  // 3.0
  451.                 unsigned long GetFileSize( unsigned long* pulSizeInBytes = NULL ) const; // 3.0
  452.                 BOOL DeleteFile( BOOL bDeleteRO = TRUE ) const;    // 3.0
  453.                 BOOL IsWriteable( long lBytes = 0L ) const;    //     3.0
  454.                 long GetDiskFreeSpace( ) const;    //     3.0
  455.                 #ifdef _WINDOWS
  456.                     BOOL CreateFile( UINT uiWin16Attrib = OF_SHARE_COMPAT ) const;    //     3.0
  457.                     #ifdef _WINDLL
  458.                         int CopyTo( LPCTSTR szDestFile, BOOL bDeleteDest = TRUE, BOOL bChangeDate = TRUE, 
  459.                                         BOOL bChangeAttrib = TRUE , BOOL bDeleteSrc = FALSE, int iBufferSize = 4096 ) const;    //    3.0
  460.                     #else
  461.                         int CopyTo( LPCTSTR szDestFile, BOOL bDeleteDest = TRUE, BOOL bChangeDate = TRUE, 
  462.                                         BOOL bChangeAttrib = TRUE , BOOL bDeleteSrc = FALSE, int iBufferSize = 16384 ) const;    //    3.0
  463.                     #endif
  464.                 #endif    //    _WINDOWS
  465.                 #ifdef _WINDOWS
  466.                     CStr GetAppDir( LPCTSTR szAppName = NULL );        
  467.                     CStr GetWinDir( );                                                      
  468.                     CStr GetWinSysDir( );                                                
  469.                 #endif
  470.                 CStr GetThisDir( );
  471.                 CStr GetTempFileName( );
  472.                 CStr GetTempDir();
  473.                 CStr FromFile( LPCTSTR szFile, BOOL bKeepString = FALSE, BOOL bAddPoints = TRUE );
  474.                 BOOL ToFile( LPCTSTR szFile, BOOL bAppend = TRUE ) const;
  475.             #endif    // _CSTR30_HASFILE
  476.  
  477.                 // ----------------------------------------------------------
  478.                 //    Single char operation
  479.                 // ----------------------------------------------------------
  480.             #ifdef _CSTR30_HASCHAR
  481.                 // Character informations
  482.                 BOOL IsCharUpper( int iIndex = 0) const;
  483.                 BOOL IsCharLower( int iIndex  =0) const;
  484.                 BOOL IsCharAlpha( int iIndex  =0) const;
  485.                 BOOL IsCharAlphaNum( int iIndex =0) const;
  486.                 BOOL IsCharNumeric( int iIndex =0) const;
  487.                 BOOL IsSpace( int iIndex =0) const;
  488.                 CStr MakeCharUpper( int iIndex =0);
  489.                 CStr MakeCharLower( int iIndex =0);
  490.             #endif    //    _CSTR30_HASCHAR
  491.  
  492.                 // ----------------------------------------------------------
  493.                 //    Find a word
  494.                 // ----------------------------------------------------------
  495.                #ifdef _CSTR30_HASFINDWORD
  496.                    int FindWord( LPCTSTR szWord, int iFrom = 0, BOOL bExact = TRUE, BOOL bMatchCase =FALSE) const;              
  497.                 BOOL FindWordInMultilineBuffer( LPCTSTR szWord, unsigned long iFromLine = 0L, int iFromCursor = 0, 
  498.                                                           unsigned long* rLineValue = NULL, int* rCursorValue = NULL, BOOL bExact = TRUE, BOOL bMatchCase =FALSE  ) const;
  499.             #endif    //    _CSTR30_HASFINDWORD
  500.  
  501.             
  502.                 // ----------------------------------------------------------
  503.                 //    Time
  504.                 // ----------------------------------------------------------
  505.         #ifdef _CSTR30_HASMOREBASIC
  506.             #if !defined(_AFXDLL) && !defined(_USRDLL)
  507.                 CString From( CTime& TimeValue, LPCTSTR szFilter = "%m/%d/%y" );    // put %d/%m/%y if you' re french...
  508.                 CString FromCurrentTime( LPCTSTR szFilter = "%m/%d/%y" ); // put %d/%m/%y if you' re french...
  509.                 #ifdef _CSTR30_HASCTIM                             
  510.                     CString FromFileTime( LPCTSTR szFile, LPCTSTR szFilter = "%m/%d/%y" );  // put %d/%m/%y if you' re french...
  511.                 #endif    //    _CSTR30_HASCTIM
  512.             #else
  513.                 #ifndef _ALREADY_DISPLAYED
  514.                     #pragma message("String Studio 3.0: Some CStr CTime functions not available with _AFXDLL or _USRDLL!")
  515.                 #endif
  516.             #endif    
  517.                 //     WARNING: the <ToTime> function use M instead of m for the month, others parameters
  518.                 //    are the same than _strftime C runtime function, and ToTime supports: [ D, Y, y, S ]
  519.                 CTime ToTime( LPCTSTR szFilter = "M/D/Y" ) const; // put y io. Y to use a date without century specification, put D/M/Y if you' re french...
  520.         #endif    //    _CSTR30_HASMOREBASIC
  521.         
  522.                    
  523.                 // ----------------------------------------------------------
  524.                 //    INI files
  525.                 // ----------------------------------------------------------
  526.             #ifdef _CSTR30_HASINI
  527.                 CStr FromIni( LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFile = NULL, int iSize = 512 );
  528.                 void ToIni( LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFile = NULL ) const;         
  529.             #endif    //    _CSTR30_HASINI
  530.  
  531.                 // ----------------------------------------------------------
  532.                 //    UNC files names
  533.                 // ----------------------------------------------------------
  534.             #ifdef _WINDOWS
  535.                 #ifdef _CSTR30_HASUNC
  536.                     BOOL IsUNC( ) const;    // 3.0
  537.                     CStr FilenameToUNC( );    // 3.0 (not implemented)
  538.                     CStr UNCToFilename( );    // 3.0 (not implemented)
  539.                 #endif     // _CSTR30_HASUNC
  540.             #endif    // _WINDOWS             
  541.                     
  542.             // don' t call the following functions!  --------------------------------------------------------------------------------
  543.             protected:     
  544.                 LPTSTR TrimTout( LPTSTR str );            // TrimAll
  545.                 LPTSTR TrimAuDebut( LPTSTR str );        // TrimBegin
  546.                 LPTSTR TrimALaFin( LPTSTR str );         // TrimEnd
  547.                 char GarbageChar;                                           
  548.             #ifdef _CSTR30_HASNUM
  549.                 void FromDouble( LPTSTR pStr, double data, int precision, LPCTSTR szDecimalPoint = "." );
  550.                 CStr NumberFormat( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." );
  551.                 void NumFormatLPSTR( LPTSTR szFormat, LPTSTR szFResult, double dValue, LPCTSTR szDecimalPoint = ".", LPCTSTR szThousandSeparator = ",");
  552.             #endif    // _CSTR30_HASNUM
  553.             #ifdef _CSTR30_HASFILE
  554.                 void DeleteADir(char far *path, BOOL bDeleteRO ) const; // 3.0
  555.                 void RecurseDeleteDir(LPTSTR path, BOOL bDeleteRO ) const;    // 3.0
  556.             #endif    //    _CSTR30_HASFILE
  557.             };    //    end of class CStr
  558.  
  559.  
  560.                 
  561. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  562. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  563. //    class CTim
  564. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  565. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  566. #ifdef _CSTR30_HASCTIM
  567.  
  568. #ifndef _CTIM
  569.     #define _CTIM
  570. #endif
  571. #ifndef _CTIM30
  572.     #define _CTIM30
  573. #endif
  574.                 
  575.             #define CTIME_OK                        0
  576.             #define CTIME_OVERFLOW          1
  577.             #define CTIME_NOTVALID              2
  578.             
  579.                             
  580.             class CTim : public CTime
  581.                 { 
  582.                 public:
  583.                     // ----------------------------------------------------------
  584.                     //    Constructors
  585.                     // ----------------------------------------------------------
  586.                     CTim( void ) : CTime(1980, 1, 1, 0, 0, 0) {};        // we can' t use the standard constructor...
  587.                     CTim( const CTime& timeSrc ) : CTime( timeSrc ) {};
  588.                     CTim( time_t time ) : CTime( time ) {};
  589.                     CTim( int nYear, int nMonth, int nDay, int nHour = 0, int nMin = 0, int nSec = 0 ): CTime( nYear, nMonth, nDay, nHour, nMin, nSec ) {};
  590.                     CTim( WORD wDosDate, WORD wDosTime ) : CTime( wDosDate, wDosTime ) {};
  591.                       #ifdef _WIN32
  592.                           CTim( const FILETIME& ft ) : CTime( ft ) {};    // 3.0
  593.                           CTim( const SYSTEMTIME& ft ) : CTime( ft ) {};    // 3.0
  594.                       #endif
  595.  
  596.                     // ----------------------------------------------------------
  597.                     //    Actions
  598.                     // ----------------------------------------------------------
  599.                     int Build( int iYear, int iMonth, int iDay, int iHour = 0, int iMin = 0, int iSec = 0 );            
  600.                     BOOL FromFile( LPCTSTR szFile );
  601.                     BOOL ToFile( LPCTSTR szFile ) const;    //    3.0
  602.                     BOOL SetDay( int iDay = 1 );        //All these methods change the current CTim object...
  603.                     BOOL SetDay( LPCTSTR szDay );
  604.                     BOOL SetMonth( int iMonth = 1 );
  605.                     BOOL SetMonth( LPCTSTR szMonth );
  606.                     BOOL SetYear( int iYear );
  607.                     BOOL SetYear( LPCTSTR szYear );
  608.                     BOOL SetSec( int iSec = 0 );
  609.                     BOOL SetSec( LPCTSTR szSec );
  610.                     BOOL SetMin( int iMin = 0 );
  611.                     BOOL SetMin( LPCTSTR szMin );
  612.                     BOOL SetHour( int iHour = 23 );
  613.                     BOOL SetHour( LPCTSTR szHour );
  614.                     BOOL IncDay( int iDay = 1 );
  615.                     BOOL IncSec( int iSec = 1 );
  616.                     BOOL IncMin( int iMin = 1 );
  617.                     BOOL IncHour( int iHour = 1 );
  618.  
  619.                     // ----------------------------------------------------------
  620.                     //    Infos
  621.                     // ----------------------------------------------------------
  622.                     BOOL IsValid() const;    //    3.0
  623.                     BOOL IsLeapYear( ) const;
  624.                     BOOL IsLastDay() const; // last day of the month
  625.                    };    //    class CTim
  626.  
  627. #endif    //    _CSTR30_HASCTIM
  628.                                               
  629. #ifndef _ALREADY_DISPLAYED
  630. #define _ALREADY_DISPLAYED
  631. #endif
  632.                                               
  633. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  634. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  635. //    class CFFind
  636. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  637. // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  638. #ifdef _CSTR30_HASCFFIND
  639.  
  640. #ifndef _CFFIND
  641.     #define _CFFIND
  642. #endif
  643. #ifndef _CFFIND30
  644.     #define _CFFIND30
  645. #endif
  646.                 
  647.                 
  648.             class CFFind    //    3.0
  649.                 { 
  650.                 public:
  651.                     // ----------------------------------------------------------
  652.                     //    Constructors and destructors
  653.                     // ----------------------------------------------------------
  654.                     CFFind() { lPos = 0L; m_strName = ""; m_win16Attrib = 0xff;
  655.                                 #ifdef _WIN32
  656.                                     m_hFFind = INVALID_HANDLE_VALUE;
  657.                                 #else
  658.                                     m_hFFind = ENOENT;
  659.                                 #endif
  660.                                 };
  661.                     CFFind( LPCTSTR szPath, UINT win16Attrib = 0xff ) { lPos = 0L; m_strName = szPath; m_win16Attrib = win16Attrib; 
  662.                                 #ifdef _WIN32
  663.                                     m_hFFind = INVALID_HANDLE_VALUE;
  664.                                 #else
  665.                                     m_hFFind = ENOENT;
  666.                                 #endif
  667.                                 };
  668.                     ~CFFind() {
  669.                                 #ifdef _WIN32
  670.                                     FindClose( m_hFFind );
  671.                                 #endif
  672.                                 lPos = 0L; m_strName = ""; m_win16Attrib = 0xff; };
  673.                     // ----------------------------------------------------------
  674.                     //    Actions
  675.                     // ----------------------------------------------------------
  676.                     BOOL FindFirst();
  677.                     BOOL FindNext();
  678.                     BOOL Find();
  679.                     void SetPath( LPCTSTR szPath, UINT win16Attrib = 0xff ) { lPos = 0L; m_strName = szPath; m_win16Attrib = win16Attrib; 
  680.                                     #ifdef _WIN32
  681.                                         m_hFFind = INVALID_HANDLE_VALUE;
  682.                                     #else
  683.                                         m_hFFind = ENOENT;
  684.                                     #endif
  685.                                     };
  686.                     void Reset( ) { lPos = 0L; m_strName = ""; m_win16Attrib = 0xff; 
  687.                                     #ifdef _WIN32
  688.                                         m_hFFind = INVALID_HANDLE_VALUE;
  689.                                     #else
  690.                                         m_hFFind = ENOENT;
  691.                                     #endif
  692.                                     };
  693.                        // ----------------------------------------------------------
  694.                     //    Informations
  695.                     // ----------------------------------------------------------
  696.                     DWORD GetAttributes() const;
  697.                     void GetCreationTime( CTim* pTim )  const;
  698.                     void GetLastAccessTime( CTim* pTim ) const;
  699.                     void GetLastWriteTime( CTim* pTim ) const;
  700.                     DWORD GetSize() const;
  701.                     void GetShortName( LPTSTR szName ) const;
  702.                     void GetLongName( LPTSTR szName ) const;
  703.                     void GetFullShortName( LPTSTR szName ) const;
  704.                     void GetFullLongName( LPTSTR szName ) const;
  705.                 #ifdef _WINDOWS
  706.                     void GetShortName( CString& szName ) const;
  707.                     void GetLongName( CString& szName ) const;
  708.                     void GetFullShortName( CString& szName ) const;
  709.                     void GetFullLongName( CString& szName ) const;
  710.                 #endif
  711.  
  712.             protected:
  713.                 #ifdef _WIN32
  714.                     WIN32_FIND_DATA m_fBuf;
  715.                     HANDLE m_hFFind;      
  716.                 #else
  717.                     struct find_t m_fBuf;
  718.                     unsigned int m_hFFind;
  719.                 #endif
  720.                 unsigned int m_win16Attrib;
  721.                 long lPos;
  722.                 CStr m_strName;        
  723.             };    //    class CFFind
  724.  
  725. #endif    //    _CSTR30_HASCFFIND                
  726.